home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / linux-headers-2.6.20-15.postinst < prev    next >
Encoding:
Text File  |  2007-04-15  |  6.9 KB  |  224 lines

  1. #!/usr/bin/perl
  2. #                              -*- Mode: Cperl -*- 
  3. # debian.postinst ---
  4. # Author           : Manoj Srivastava ( srivasta@pilgrim.umass.edu )
  5. # Created On       : Sat Apr 27 05:42:43 1996
  6. # Created On Node  : melkor.pilgrim.umass.edu
  7. # Last Modified By : Manoj Srivastava
  8. # Last Modified On : Sat Aug  5 13:20:22 2006
  9. # Last Machine Used: glaurung.internal.golden-gryphon.com
  10. # Update Count     : 45
  11. # Status           : Unknown, Use with caution!
  12. # HISTORY          :
  13. # Description      :
  14. #
  15. #
  16. #
  17. #  arch-tag: 1c716174-2f0a-476d-a626-a1322e62503a
  18. #
  19.  
  20.  
  21. $|=1;
  22.  
  23. # Predefined values:
  24. my $version           = "2.6.20-15";
  25. my $link_in_boot      = "";  # Should be empty, mostly
  26. my $no_symlink        = "";   # Should be empty, mostly
  27. my $reverse_symlink   = "";   # Should be empty, mostly
  28. my $do_symlink        = "Yes";  # target machine defined
  29. my $do_boot_enable    = "Yes";  # target machine defined
  30. my $do_bootfloppy     = "Yes";  # target machine defined
  31. my $do_bootloader     = "Yes";  # target machine defined
  32. my $move_image        = '';     # target machine defined
  33. my $kimage            = "bzImage";   # Should be empty, mostly
  34. my $loader            = "lilo"; # lilo, silo, quik, palo, vmelilo, nettrom, arcboot or delo
  35. my $image_dir         = "/boot";        # where the image is located
  36. my $clobber_modules   = '';          # target machine defined
  37. my $relative_links    = "";          # target machine defined
  38. my $initrd            = "";        # initrd kernel
  39. my $mkimage           = "";   # command to generate the initrd image
  40. my $do_initrd         = '';     # Normally we do not
  41. my $warn_initrd       = 'YES';  # Normally we do
  42. my $use_hard_links    = ''; # hardlinks do not work across fs boundaries
  43. my $postinst_hook     = '';          #Normally we do not
  44. my $postrm_hook       = '';          #Normally we do not
  45. my $preinst_hook      = '';          #Normally we do not
  46. my $prerm_hook        = '';          #Normally we do not
  47. my $minimal_swap      = '';          # Do not swap symlinks
  48. my $ignore_depmod_err = '';          # normally we do not
  49. my $relink_src_link   = 'YES'; # There is no harm in checking the link
  50. my $relink_build_link = 'YES'; # There is no harm in checking the link
  51. my $force_build_link  = '';    # There is no harm in checking the link
  52. my $official_image    = "YES";  # only true for official images
  53. my $arch              = "i386"; #  should be same as dpkg --print-installation-architecture
  54. my $kernel_arch       = "i386";
  55. my $ramdisk           = "";  # List of tools to create initial ram fs.
  56. my $initrddep         = "";  # List of dependencies for such tools
  57. my $package_name    = "linux-image-$version";
  58.  
  59.  
  60. # Ignore all invocations uxcept when called on to configure.
  61. exit 0 unless ($ARGV[0] && $ARGV[0] =~ /configure/);
  62.  
  63. #known variables
  64. my $image_dest      = "/";
  65. my $realimageloc    = "/$image_dir/";
  66. my $have_conffile   = "";
  67. my $silent_modules  = '';
  68. my $silent_loader   = '';
  69. my $modules_base    = '/lib/modules';
  70. my $CONF_LOC        = '/etc/kernel-img.conf';
  71. # remove multiple leading slashes; make sure there is at least one.
  72. $realimageloc  =~ s|^/*|/|o;
  73. $realimageloc  =~ s|/+|/|o;
  74.  
  75. my $architecture;
  76. chomp($architecture = `dpkg --print-installation-architecture`);
  77. $architecture = "ppc" if $architecture eq "powerpc";
  78. $architecture = "parisc" if $architecture eq "hppa";
  79. $architecture = "mips" if $architecture eq "mipsel";
  80. $architecture = "x86_64" if $architecture eq "amd64";
  81.  
  82. my $stop_and_read     = 0;
  83. my $src_postinst_hook = '';
  84.  
  85. # most of our work is done in /usr/src.
  86. chdir '/usr/src' or die "Could not chdir to /usr/src:$!";
  87.  
  88. if (-d "$package_name") {
  89.  
  90.  
  91.   # See if we have a kernel image of the same version already installed.
  92.   if ( -d "$modules_base/$version" && -d "/usr/src/$package_name" ) {
  93.     if (! -e "$modules_base/$version/build" ) {
  94.       my $result = symlink ("/usr/src/linux-headers-$version",
  95.                             "$modules_base/$version/build");
  96.       if (! $result) {
  97.         warn "Could not link /usr/src/linux-headers-$version to $modules_base/$version/build:$!"
  98.       }
  99.     }
  100.   }
  101.  
  102.   chdir "/usr/src/$package_name/include" ||
  103.     die "Could not chdir to  /usr/src/$package_name/include:$!";
  104.  
  105.   if (! -d "asm-$architecture") {
  106.     warn "/usr/src/$package_name/include/asm-$architecture does not exist.\n";
  107.   }
  108.   elsif (-e 'asm') {
  109.     if (! -l 'asm') {
  110.       warn "/usr/src/$package_name/include/asm is not a symlink.\n";
  111.       $stop_and_read++;
  112.     }
  113.     else {
  114.       my $target=readlink 'asm';
  115.       if ("$target" ne "asm-$architecture") {
  116.     if (! unlink 'asm') {
  117.       warn "could not unlink /usr/src/$package_name/include/asm: $!\n";
  118.       warn "It points to /usr/src/$package_name/include/$target\n";
  119.       warn  "rather than at /usr/src/$package_name/include/asm-$architecture\n";
  120.       $stop_and_read++;
  121.     }
  122.     else {
  123.       if (! symlink "asm-$architecture", 'asm') {
  124.         warn "Could not link /usr/src/$package_name/include/asm:$!\n";
  125.         warn "to /usr/src/$package_name/include/asm-$architecture\n";
  126.         $stop_and_read++;
  127.       }
  128.     }
  129.       }
  130.     }
  131.   }
  132. }
  133.  
  134. chdir '/usr/src' or die "Could not chdir to /usr/src:$!";
  135.  
  136. # if ($stop_and_read) {
  137. #   my $answer;
  138. #   print STDERR " Please Hit return to continue.";
  139. #   $answer = <STDIN>;
  140. # }
  141.  
  142. if (-r "$CONF_LOC" && -f "$CONF_LOC"  ) {
  143.   if (open(CONF, "$CONF_LOC")) {
  144.     while (<CONF>) {
  145.       chomp;
  146.       s/\#.*$//g;
  147.       next if /^\s*$/;
  148.  
  149.       $src_postinst_hook      = "$1"  if /src_postinst_hook\s*=\s*(\S+)/ig;
  150.       $header_postinst_hook   = "$1"  if /header_postinst_hook\s*=\s*(\S+)/ig;
  151.     }
  152.     close CONF;
  153.     $have_conffile = "Yes";
  154.   }
  155. }
  156.  
  157. sub exec_script {
  158.   my $type   = shift;
  159.   my $script = shift;
  160.   print STDERR "Running $type hook script $script.\n";
  161.   system ("$script $version $realimageloc$kimage-$version") &&
  162.     print STDERR "User $type hook script [$script] ";
  163.   if ($?) {
  164.     if ($? == -1) {
  165.       print STDERR "failed to execute: $!\n";
  166.     }
  167.     elsif ($? & 127) {
  168.       printf STDERR "died with signal %d, %s coredump\n",
  169.         ($? & 127),  ($? & 128) ? 'with' : 'without';
  170.     }
  171.     else {
  172.       printf STDERR "exited with value %d\n", $? >> 8;
  173.     }
  174.     exit $? >> 8;
  175.   }
  176. }
  177. sub run_hook {
  178.   my $type   = shift;
  179.   my $script = shift;
  180.   if ($script =~ m,^/,) {
  181.     # Full path provided for the hook script
  182.     if (-x "$script") {
  183.       &exec_script($type,$script);
  184.     }
  185.     else {
  186.       die "The provided $type hook script [$script] could not be run.\n";
  187.     }
  188.   }
  189.   else {
  190.     # Look for it in a safe path
  191.     for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
  192.       if (-x "$path/$script") {
  193.         &exec_script($type, "$path/$script");
  194.         return 0;
  195.       }
  196.     }
  197.     # No luck
  198.     print STDERR "Could not find $type hook script [$script].\n";
  199.     die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
  200.   }
  201. }
  202.  
  203. ## Run user hook script here, if any
  204. if (-x "$src_postinst_hook") {
  205.   &run_hook("postinst", $src_postinst_hook);
  206. }
  207. if (-x "$header_postinst_hook") {
  208.   &run_hook("postinst", $header_postinst_hook);
  209. }
  210.  
  211.  
  212.  
  213. exit 0;
  214.  
  215. __END__
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.